package com.example.demo.LeetCode.arr;

public class SearchInsert {
    public int solution(int[] nums,int target){
        int size = nums.length;
        int left = 0,right = size -1;
        while (left <= right){
            int mid = (right - left) / 2 + left;
            int val = nums[mid];
            if (val == target){
                return target;
            }
            if (val < target){
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return left;
    }
}
